<?php


namespace app\admin\model;


use think\Model;

class ButtJoin extends Model
{
    protected $autoWriteTimestamp = true;

    /**
     * @param $data
     * @return mixed|null
     * 获取最新数据
     */
    public static function getButt($data,$serverType)
    {
       $resJoin = ButtJoin::field("staff_no")
//            ->where("user_no",$data["user_no"])
            ->where("url",$data["url"])
            ->where("server_type",$serverType)
            ->order("create_time desc")
            ->find();
       $staffNo = "";
       if($resJoin) {
           $resST = Staff::field("staff_no")->where("staff_no",$resJoin["staff_no"])->where("delete_time",0)->find();
          if($resST){
              $staffNo = $resST["staff_no"];
          }
       }
       return $staffNo;
    }

    /**
     * @param $data
     * @param $serverType
     * @return string
     */
    public static function saveButt($data,$serverType)
    {
        $arr["user_no"] = $data["user_no"];
        $arr["staff_no"] = $data["staff_no"];
        $arr["url"] = $data["url"];
        $arr["server_type"] = $serverType;
        $res = ButtJoin::create($arr);
        if (!$res){
            return "添加失败";
        }
        return "";
    }

}